home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / xvisrc.zip / UNIX.H < prev    next >
C/C++ Source or Header  |  1992-07-28  |  4KB  |  159 lines

  1. /* Copyright (c) 1990,1991,1992 Chris and John Downey */
  2. /***
  3.  
  4. * @(#)unix.h    2.1 (Chris & John Downey) 7/29/92
  5.  
  6. * program name:
  7.     xvi
  8. * function:
  9.     PD version of UNIX "vi" editor, with extensions.
  10. * module name:
  11.     unix.h
  12. * module function:
  13.     Definitions for UNIX system interface module.
  14. * history:
  15.     STEVIE - ST Editor for VI Enthusiasts, Version 3.10
  16.     Originally by Tim Thompson (twitch!tjt)
  17.     Extensive modifications by Tony Andrews (onecom!wldrdg!tony)
  18.     Heavily modified by Chris & John Downey
  19.  
  20. ***/
  21.  
  22. #include <errno.h>
  23. #include <fcntl.h>
  24. #if defined(BSD) && !defined(__STDC__)
  25. #   include <sys/time.h>
  26. #else
  27. #   include <time.h>
  28. #endif
  29.  
  30. #if defined(SUNVIEW) || defined(XVIEW)
  31. #   include "sunview.h"
  32. #else
  33. #   include "termcap.h"
  34. #endif
  35.  
  36. /*
  37.  * Default value for helpfile parameter.
  38.  */
  39. #ifndef HELPFILE
  40. #   define  HELPFILE    "/usr/lib/xvi.help"
  41. #endif
  42.  
  43. #if defined(sun) || defined(ultrix) || defined(XENIX) || defined(__STDC__)
  44. #   define SETVBUF_AVAIL
  45.     /*
  46.      * These are the buffer sizes we use for reading & writing files.
  47.      */
  48. #   define  READBUFSIZ    16384
  49. #   define  WRTBUFSIZ    16384
  50. #endif
  51.  
  52. /*
  53.  * If we don't have an ANSI compiler, strerror() is implemented in unix.c.
  54.  */
  55. #define STRERROR_AVAIL
  56.  
  57. #ifndef    __STDC__
  58.     /*
  59.      * Conditionally compile this to be safe.
  60.      */
  61.     extern const char    *strerror P((int));
  62. #endif
  63.  
  64. #ifdef sun
  65.     /*
  66.      * getwd() is a system call, which doesn't need to run the pwd
  67.      * program (as getcwd() does).
  68.      */
  69.     extern char        *getwd P((char *));
  70. #   define getcwd(p,s)    getwd(p)
  71. #endif
  72.  
  73. /*
  74.  * Macros to open files in binary mode.
  75.  */
  76. #define fopenrb(f)    fopen((f),"r")
  77. #define fopenwb(f)    fopen((f),"w")
  78.  
  79. /*
  80.  * ANSI C libraries should have remove(), but unlink() does exactly
  81.  * the same thing.
  82.  */
  83. #define remove(f)    unlink(f)
  84.  
  85. /*
  86.  * BSD doesn't provide memcpy, but bcopy does the same thing.
  87.  * Similarly, strchr=index and strrchr=rindex.
  88.  * However, any __STDC__ environment must provide these,
  89.  * and SunOS provides them too, as does ULTRIX.
  90.  */
  91. #if defined(BSD) && !defined(__STDC__) && !defined(sun) && !defined(ultrix)
  92. #   define  memcpy(to, from, n)    bcopy((from), (to), (n))
  93. #   define  strchr        index
  94. #   define  strrchr        rindex
  95. #endif
  96.  
  97. /*
  98.  * System-dependent constants - these are needed by file i/o routines.
  99.  */
  100. #ifdef    BSD
  101. #   include <sys/param.h>
  102. #   include <sys/dir.h>
  103. #   include <sys/file.h>    /* get W_OK define for access() */
  104. #else    /* not BSD */
  105.     /*
  106.      * I think these are right for System V. (jmd)
  107.      */
  108. #   define  MAXPATHLEN    1024    /* max length of full path name */
  109. #   define  MAXNAMLEN    14    /* max length of file name */
  110. #endif    /* BSD */
  111.  
  112. #ifndef W_OK
  113. #   define    F_OK    0
  114. #   define    W_OK    2
  115. #endif
  116.  
  117. /*
  118.  * exists(): TRUE if file exists.
  119.  */
  120. #define exists(f)    (access((f),F_OK) == 0)
  121.  
  122. /*
  123.  * can_write(): TRUE if file does not exist or exists and is writeable.
  124.  */
  125. #define can_write(f)    (access((f),F_OK) != 0 || access((f), W_OK) == 0)
  126.  
  127. #define    DIRSEPS        "/"    /* directory separators within pathnames */
  128.  
  129. /*
  130.  * Default file format.
  131.  */
  132. #define DEF_TFF        fmt_UNIX
  133.  
  134. /*
  135.  * These are needed for the termcap terminal interface module.
  136.  */
  137. #define oflush()    (void) fflush(stdout)
  138. #define moutch(c)    putchar(c)
  139.  
  140. /*
  141.  * Declarations for standard UNIX functions.
  142.  */
  143. extern    int        rename P((const char *, const char *));
  144.  
  145. /*
  146.  * Declarations for system interface routines in unix.c.
  147.  */
  148. extern    char        *fexpand P((char *));
  149. extern    void        foutch P((int));
  150. extern    void        delay P((void));
  151. extern    void        sys_init P((void));
  152. extern    void        sys_startv P((void));
  153. extern    void        sys_endv P((void));
  154. extern    void        sys_exit P((int));
  155. extern    int        call_shell P((char *));
  156. extern    int        call_system P((char *));
  157. extern    bool_t        sys_pipe P((char *, int (*)(FILE *), long (*)(FILE *)));
  158. extern    char        *tempfname P((char *));
  159.